﻿using System.Data.Entity.ModelConfiguration;
using CH.FourBoards.LagerWalti.Persistence.Entities;

namespace CH.FourBoards.LagerWalti.Persistence.Mapping
{
    internal class TransactionTypeMap : EntityTypeConfiguration<TransactionType>
    {
        internal TransactionTypeMap()
        {
            #region Primary Key and Row Version

            HasKey(t => t.Id);

            // RowVersion for optimistic locking
            //Property(t => t.Version).IsRowVersion();

            #endregion

            #region Foreign Keys
            /*
            Property(t => t.KindId)
                .IsRequired();

            Property(t => t.StateId)
                .IsRequired();

            Property(t => t.ParentId)
                .IsOptional();

            Property(t => t.TemplateId)
                .IsOptional();

            Property(t => t.ExecutionId)
                .IsOptional();

            Property(t => t.ItemTemplateId)
                .IsOptional();
            */
            #endregion

            #region Properties

            Property(t => t.Name).IsRequired().HasMaxLength(100);

            #endregion

            #region Relationships

            /*
            HasRequired(t => t.Kind)
                .WithMany()
                .HasForeignKey(t => t.KindId);
            HasRequired(t => t.State)
                .WithMany()
                .HasForeignKey(t => t.StateId);
            HasOptional(t => t.Parent)
                .WithMany()
                .HasForeignKey(t => t.ParentId);
            HasMany(t => t.Properties)
                .WithOptional()
                .HasForeignKey(t => t.InformationItemId);
            HasOptional(t => t.Template)
                .WithMany()
                .HasForeignKey(t => t.TemplateId);
            HasOptional(t => t.Execution)
                .WithMany()
                .HasForeignKey(t => t.ExecutionId);
            HasOptional(t => t.ItemTemplate)
                .WithMany()
                .HasForeignKey(t => t.ItemTemplateId);
            */

            #endregion

        }
    }
}
